Skip to content

[in progress] Abilities API: Add a core/settings ability#12141

Open
jorgefilipecosta wants to merge 3 commits into
WordPress:trunkfrom
jorgefilipecosta:add/core-settings-ability
Open

[in progress] Abilities API: Add a core/settings ability#12141
jorgefilipecosta wants to merge 3 commits into
WordPress:trunkfrom
jorgefilipecosta:add/core-settings-ability

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Jun 9, 2026

Copy link
Copy Markdown
Member

Part of: WordPress/ai#40
Ticket: https://core.trac.wordpress.org/ticket/64605

Summary

Adds a read-only core/settings ability to the Abilities API. It returns WordPress settings — those flagged with a new show_in_abilities registration arg — as a flat name => value map, with per-setting metadata (type, title, description, default) carried in the output schema. Callers can filter by settings group or by settings name (mutually exclusive). Requires manage_options.

This is a flat-output alternative to #10747. The logic lives in a new internal WP_Settings_Abilities class (src/wp-includes/abilities/class-wp-settings-abilities.php), structured so a future core/manage-settings write ability can reuse its helpers (get_exposed_settings(), value_schema(), cast_value()).

Test plan

In wp-admin, open the browser console and call the ability's run endpoint with wp.apiFetch:

// All exposed settings (flat name => value map).
await wp.apiFetch( {
	path: wp.url.addQueryArgs( '/wp-abilities/v1/abilities/core/settings/run' ),
} );

// Filter by group.
await wp.apiFetch( {
	path: wp.url.addQueryArgs( '/wp-abilities/v1/abilities/core/settings/run', {
		input: { group: 'reading' },
	} ),
} );

// Filter by specific settings (by name).
await wp.apiFetch( {
	path: wp.url.addQueryArgs( '/wp-abilities/v1/abilities/core/settings/run', {
		input: { settings: [ 'blogname', 'posts_per_page' ] },
	} ),
} );
  • Returns a flat name => value map with typed values (e.g. posts_per_page is an int, use_smilies a bool)
  • group and settings filters narrow the result; supplying both at once is rejected
  • A non-admin user (no manage_options) is denied

PHPUnit coverage added in tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsAbility.php (including a test that a setting registered with show_in_abilities is exposed by the ability).

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta, justlevine.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@jorgefilipecosta jorgefilipecosta changed the title Abilities API: Add a core/settings ability [in progress] Abilities API: Add a core/settings ability Jun 9, 2026
@justlevine

Copy link
Copy Markdown

@jorgefilipecosta can you link this to the trac ticket please? I don't have edit perms in this repo.
https://core.trac.wordpress.org/ticket/64605

@jorgefilipecosta jorgefilipecosta force-pushed the add/core-settings-ability branch from 073df67 to c948c7a Compare June 12, 2026 15:01
@gziolo gziolo self-requested a review June 15, 2026 12:31
@jorgefilipecosta

Copy link
Copy Markdown
Member Author

@jorgefilipecosta can you link this to the trac ticket please? I don't have edit perms in this repo. core.trac.wordpress.org/ticket/64605

Nice catch the ticket mention was added.

Add a read-only core/settings ability that returns WordPress settings as a flat
name => value map. Only settings flagged with the new show_in_abilities
registration arg are exposed; callers can filter by settings group or by name
(mutually exclusive). Requires the manage_options capability.

The logic lives in a new internal WP_Settings_Abilities class, structured so a
future core/manage-settings write ability can reuse its helpers.
'settings' reads more naturally than 'slugs' for filtering an abilities-exposed
settings map by name.
@jorgefilipecosta jorgefilipecosta force-pushed the add/core-settings-ability branch from c948c7a to a28c976 Compare June 15, 2026 19:32
… tests

Register a setting with show_in_abilities and assert it is exposed in the
ability's input enum, output schema, and execute output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants